package com.example.spdemo.mapper;

import com.example.spdemo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Delete;

import java.util.List;
@Mapper
public interface UserMapper {

    @Select("SELECT * from sys_user")
    List<User> findAll();

    @Insert("INSERT into sys_user(username, password, nickname, email, phone, address) VALUES (#{username},#{password},#{nickname},#{email},#{phone},#{address})")
    Integer insert(User user);

    @Update("UPDATE sys_user SET username = #{username}, password = #{password}, nickname = #{nickname}, email = #{email}, phone = #{phone}, address = #{address} WHERE id = #{id}")
    Integer update(User user);
    
    @Delete("DELETE FROM sys_user WHERE id = #{id}")
    Integer deleteById(Integer id);
    
    @Select("SELECT * FROM sys_user WHERE id = #{id}")
    User findById(Integer id);
}